package com.tron.thread.singleThread;

public class UserThread extends Thread {
    private Gate gate;
    private String userName;
    private String userAddress;

    public UserThread(Gate gate, String userName, String userAddress) {
        this.gate = gate;
        this.userName = userName;
        this.userAddress = userAddress;
    }

    @Override
    public void run() {
        System.out.println(userName+"Begin...");
        while (gate.isOpen) {
//            System.out.println("No."+gate.count +" -> " + userName+": 准备通过..."); // 加了这里以后不再出现线程错误,不明白是什么原因
            gate.pass(userName, userAddress);
        }
    }

}
